package co.gov.das.fotogps.movil;

import java.io.IOException;
import java.io.OutputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;


// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.1020A7B1-D072-861C-33C2-CD36F9568276]
// </editor-fold> 
public class AdminConexion {

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.518B9493-BA62-DE85-4EA7-4B0336BAB3EE]
    // </editor-fold> 
    private String servidor;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.1AEE7108-4162-CDC5-2747-6825D43815CC]
    // </editor-fold> 
    private int puerto;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.CFA71030-81C4-6863-BB0C-9A2008B32BCA]
    // </editor-fold> 
    private String proxy;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.947F76B9-1341-86FE-B572-86B80B1E54A9]
    // </editor-fold> 
    public AdminConexion () {
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.DBD97A3D-3F2B-387D-6D4D-BEB9AB44FBF1]
    // </editor-fold> 
    public String getProxy () {
        return proxy;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.E1DC2541-4772-B0D1-D6F1-E06FD6BBAE5A]
    // </editor-fold> 
    public void setProxy (String val) {
        this.proxy = val;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.F40532BC-9F3F-4B96-E7E9-D48255362FBD]
    // </editor-fold> 
    public int getPuerto () {
        return puerto;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.395FC509-2786-2628-1A33-3E739D4A5C23]
    // </editor-fold> 
    public void setPuerto (int val) {
        this.puerto = val;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.2DD14A5B-079E-C9F0-BE94-A065BB160475]
    // </editor-fold> 
    public String getServidor () {
        return servidor;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.64A139D4-2201-8950-CC39-9A01727EEF45]
    // </editor-fold> 
    public void setServidor (String val) {
        this.servidor = val;
    }

    //Metodo para enviar foto
    public void enviarFoto(Fotografia fotografia) throws IOException {
        String url = "http://localhost:8080/web/servlet/co.gov.das.fotogpsserver.FotoGPSServlet";
        FotoGPSClient client = new FotoGPSClient(url);
        client.enviarFoto(fotografia);
//        String url = "http://localhost:8080/FotoGPSServer/";
//        OutputStream os = null;
//        //Connect to the server
//        HttpConnection hc = (HttpConnection) Connector.open(url);
//        hc.setRequestMethod(HttpConnection.POST);
//        //Verifica conexion
//        if (hc.getResponseCode() == HttpConnection.HTTP_OK) {
//            os = hc.openOutputStream();
//            os.write(fotografia.toString().getBytes());
//        }
//        //Closing time...
//        hc.close();
//        os.close();
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.09C8EE20-F013-BCAC-196F-38B0538D3B18]
    // </editor-fold> 
    public void conectar () {
    }

}

